package com.bailian.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bailian.common.annotation.Log;
import com.bailian.common.core.controller.BaseController;
import com.bailian.common.core.domain.AjaxResult;
import com.bailian.common.enums.BusinessType;
import com.bailian.system.domain.BlNewsType;
import com.bailian.system.service.IBlNewsTypeService;
import com.bailian.common.utils.poi.ExcelUtil;
import com.bailian.common.core.page.TableDataInfo;

/**
 * 咨询类型Controller
 * 
 * @author bailian
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/system/news_type")
public class BlNewsTypeController extends BaseController
{
    @Autowired
    private IBlNewsTypeService blNewsTypeService;

    /**
     * 查询咨询类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:news_type:list')")
    @GetMapping("/list")
    public TableDataInfo list(BlNewsType blNewsType)
    {
        startPage();
        List<BlNewsType> list = blNewsTypeService.selectBlNewsTypeList(blNewsType);
        return getDataTable(list);
    }

    /**
     * 导出咨询类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:news_type:export')")
    @Log(title = "咨询类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlNewsType blNewsType)
    {
        List<BlNewsType> list = blNewsTypeService.selectBlNewsTypeList(blNewsType);
        ExcelUtil<BlNewsType> util = new ExcelUtil<BlNewsType>(BlNewsType.class);
        util.exportExcel(response, list, "咨询类型数据");
    }

    /**
     * 获取咨询类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:news_type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(blNewsTypeService.selectBlNewsTypeById(id));
    }

    /**
     * 新增咨询类型
     */
    @PreAuthorize("@ss.hasPermi('system:news_type:add')")
    @Log(title = "咨询类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlNewsType blNewsType)
    {
        return toAjax(blNewsTypeService.insertBlNewsType(blNewsType));
    }

    /**
     * 修改咨询类型
     */
    @PreAuthorize("@ss.hasPermi('system:news_type:edit')")
    @Log(title = "咨询类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlNewsType blNewsType)
    {
        return toAjax(blNewsTypeService.updateBlNewsType(blNewsType));
    }

    /**
     * 删除咨询类型
     */
    @PreAuthorize("@ss.hasPermi('system:news_type:remove')")
    @Log(title = "咨询类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(blNewsTypeService.deleteBlNewsTypeByIds(ids));
    }
}
